﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FTradeReceivablesEditImport.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.FTradeModel.ImortDate.FTradeReceivablesEditImport" %>

<%--变更收款条款--%>
<script type="text/javascript">

    $(document).ready(function () {
        $("#FTradeReceivablesUpdateSaleTypeOld_Price,#FTradeReceivablesUpdateSaleTypeOld_GPSFeiYong,#FTradeReceivablesUpdateSaleTypeOld_YueCuXiaoJinE").change(function () {
            changeHHeTongJinE()
        })
        function changeHHeTongJinE() {
            //处理合同金额
            if ($(this).val() == "")
                $(this).val(0);
            var Price = parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_Price").val());
            var GPSFeiYong = parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_GPSFeiYong").val());
            var YueCuXiaoJinE = parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_YueCuXiaoJinE").val());

            $("#FTradeReceivablesUpdateSaleTypeOld_HeTongJinE").val((-1) * Price + GPSFeiYong + YueCuXiaoJinE);
        }
        $("#FTradeReceivablesUpdateSaleTypeOld_GPSFeiYong").val((-1) * parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_GPSFeiYong").val()));
        $("#FTradeReceivablesUpdateSaleTypeOld_YueCuXiaoJinE").val((-1) * parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_YueCuXiaoJinE").val()))

        changeHHeTongJinE();

        //处理合同金额
        $("#FTradeReceivablesUpdateSaleType_Price,#FTradeReceivablesUpdateSaleType_GPSFeiYong,#FTradeReceivablesUpdateSaleType_YueCuXiaoJinE").change(function () {
            if ($(this).val() == "")
                $(this).val(0);
            var Price = parseFloat($("#FTradeReceivablesUpdateSaleType_Price").val());
            var GPSFeiYong = parseFloat($("#FTradeReceivablesUpdateSaleType_GPSFeiYong").val());
            var YueCuXiaoJinE = parseFloat("-" + $("#FTradeReceivablesUpdateSaleType_YueCuXiaoJinE").val());

            $("#FTradeReceivablesUpdateSaleType_HeTongJinE").val(Price + GPSFeiYong + YueCuXiaoJinE);

        })
    })

    function validateCallbackFTradeReceivablesUpdateSaleType(form, callback) {

        var $form = $(form);
        var $oldHeTongHao = "<%=obj.HeTongHao %>";
        var $newHeTongHao = $("#FTradeReceivablesUpdateSaleType_HeTongHao").val();
        //var $table = $form.find("tbody.ODailyAdd");
        var $newXiaoShouLeiXing = $("#FTradeReceivablesSaleTypeAdd_XiaoShouLeiXing").val();
        if ($newXiaoShouLeiXing == "请选择") {
            alertMsg.warn("请先选择一个 新的收款条款");
            return false;
        }
//        if ($oldHeTongHao == $newHeTongHao) {
//            alertMsg.warn("变更收款条款后，需要更改合同号");
//            $form.find("#FTradeReceivablesUpdateSaleType_HeTongHao").focus();
//            return false;
//        }
        //新增时需要处理 金额是否与合同金额一致
        var $XiaoShouLeiXing = $("#FTradeReceivablesSaleTypeAdd_XiaoShouLeiXing").val();
        var $HeTongJinE = $("#FTradeReceivablesUpdateSaleType_HeTongJinE").val();
        var $inputPageJinE = 0;
        $("#FTradeReceivablesSaleTypeAdd_ShowXXLSPage").find(":text[name='Page_JinE']").each(function () {
            $inputPageJinE = parseFloat($inputPageJinE) + parseFloat($(this).val());
        });
        //alert(parseFloat($HeTongJinE).toFixed(3));
       // alert(parseFloat($inputPageJinE).toFixed(3));

        if (parseFloat($HeTongJinE).toFixed(4) != parseFloat($inputPageJinE).toFixed(4)) {
            alertMsg.warn("合同金额与收款条款[" + $XiaoShouLeiXing + "]相应金额不一致,请检查更改后再提交.");
            return false;
        }
        //
        return validateCallback(form, callback);
    }
</script>
<div class="pageContent">
    <form method="post" action="FTradeModel/ImortDate/FTradeReceivablesEditImport.aspx?ajaxmethod=addimport&FTradeID=<%=FTradeID %>" class="pageForm required-validate" onsubmit="return validateCallbackFTradeReceivablesUpdateSaleType(this, navTabAjaxDone);">
    <div class="pageFormContent" layouth="56">
       

        <h2 style="padding: 5px 0px 5px 6px; border-bottom: 1px solid #B8D0D6;">
            改分期后合同基本信息( <b>系统ID:<%=obj.FTradeID %></b> )
        </h2>
        <p>
            <label>
                合 同 号：</label>
            <input name="HeTongHao" type="text" id="FTradeReceivablesUpdateSaleType_HeTongHao"
                class="required" value="<%=obj.HeTongHao %>" />
        </p>
        <p>
            <label>
                销售时间：</label>
            <input name="XiaoShouShiJian" class="required date" type="text" value="<%=obj.XiaoShouShiJian.ToString("yyyy-MM-dd") %>"
                alt="请输入销售时间" />
        </p>
        <p>
            <label>
                经 销 商：</label>
            <input name="JingXiaoShang" type="text" value="<%=obj.JingXiaoShang %>" class="required textInput autocomplete"
                autocompletehref="<%=AutoCompleteRequestUrl %>?ajaxmethod=getagentlist" swidth="300" />
        </p>
        <p>
            <label>
                营业经理：</label>
            <input name="YingYeJingLi" class="required" type="text" value="<%=obj.YingYeJingLi %>"
                alt="请输入营业经理" />
        </p>
        <div class="divider">
        </div>
        <p>
            <label>
                型 号：</label>
            <%=GetMacType("select", "XingHao", obj.XingHao)%>
        </p>
        <p>
            <label>
                机 号：</label>
            <input name="JiHao" class="required" type="text" size="" alt="" value="<%=obj.JiHao %>" />
        </p>
        <div class="divider">
        </div>
        <p>
            <label>
                单 价：</label>
            <input id="FTradeReceivablesUpdateSaleType_Price" name="Price" class="required inputFloat"
                type="text" value="<%=obj.Price %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
        <p>
            <label>
                GPS费 用：</label>
            <input id="FTradeReceivablesUpdateSaleType_GPSFeiYong" name="GPSFeiYong" class="required inputFloat"
                type="text" value="<%=obj.GPSFeiYong %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
        <p>
            <label>
                月促销折让金额：</label>
            <span class="unit" style="float: left">-</span>
            <input id="FTradeReceivablesUpdateSaleType_YueCuXiaoJinE" name="YueCuXiaoJinE" class="required inputFloat"
                type="text" value="<%=Math.Abs(obj.YueCuXiaoJinE) %>" size="" alt="" />
            <span class="unit">元(负数)</span>
        </p>
          <p>
			<label>GPS 号：</label>
			<input name="GPSNum" class="" type="text" value="<%=obj.GPSNum %>" size="" alt="" readonly/>
		</p>
        <div class="divider">
        </div>
        <p>
            <label>
                合同金额：</label>
            <input id="FTradeReceivablesUpdateSaleType_HeTongJinE" name="HeTongJinE" class="required inputFloat"
                type="text" value="<%=obj.HeTongJinE %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
        <p>
            <label>
                到期日：</label>
            <input name="DaoQiRi" class="" type="text" value="<%=obj.DaoQiRi %>" alt="" />
        </p>
        <div style="clear: both;">
        </div>
        <label>
            合同付款条款：</label>
        <textarea name="FuKuanTiaoKuan" cols="80" rows="4"><%=obj.FuKuanTiaoKuan%></textarea>
        <div style="clear:both;"></div>
                     <p>
				        <label>已收款项：</label>
				        <input name="YiShouKuanXiang" class="" type="text" readonly value="<%=obj.YiShouKuanXiang %>"　readonly />
			        </p>
                    <p>
				        <label>未收款项：</label>
				        <input name="WeiShouKuanXiang" class="" type="text" readonly value="<%=obj.WeiShouKuanXiang %>"　readonly />
			        </p>
                    <p>
				        <label>逾期款项：</label>
				        <input name="YuQiKuanXiang" class="" type="text" readonly value="<%=obj.YuQiKuanXiang %>"  alt=""/>
			        </p>
        <div class="divider" style="clear: both;">
        </div>
        <label style="color: Green; font-weight: bold;">收款条款：</label>
        <%--<select id="FTradeReceivablesSaleTypeAdd_XiaoShouLeiXing" name="XiaoShouLeiXing"
            class="required" >
            <%=GetXiaoShouLeiXing(obj.XiaoShouLeiXing)%>
        </select>--%>

        <input name="XiaoShouLeiXing" value="<%=obj.XiaoShouLeiXing%>" readonly />

        <div id="FTradeReceivablesUpdateSaleType_ShowSummary" style=" line-height:30px; color:Red; font-weight:bold;" >
                       
        </div>
        <div style="clear: both;">
        </div>
        <div id="FTradeReceivablesSaleTypeAdd_ShowXXLSPage" style="border: 1px dotted #B8D0D6;
            margin: 5px 0px;">
            <%--显示显示销售对应的配置--%>
        </div>
      
        <script type="text/javascript">
            $(document).ready(function () {

                $("#FTradeReceivablesSaleTypeAdd_XiaoShouLeiXing").change(function () {
                    changeXiaoShouLeiXingSaleTypeAdd($(this).val());
                })

                function changeXiaoShouLeiXingSaleTypeAdd(key) {
                    // key = encodeURI(key);

                    //是否能更改
                    $.ajax({
                        type: 'get',
                        url: 'FTradeModel/FTradeReceivablesUpdateSaleType.aspx?ajaxmethod=canchange&oldLeiXing=' + encodeURI("<%=obj.XiaoShouLeiXing %>") + "&newLeiXing=" + encodeURI(key),
                        dataType: "text",
                        async: false,
                        cache: false,
                        success: function (json) {
                            try {
                                if (json == "true") {
                                    var url = "FTradeModel/GetPageFTradeSaleTypeConfigAdd.aspx?key=" + encodeURI(key)
                                    $("#FTradeReceivablesSaleTypeAdd_ShowXXLSPage").loadUrl(url);
                                    //
                                    url = "FTradeModel/GetPageFTradeSaleTypeConfigAdd.aspx?ajaxmethod=getconfigsummary&key=" + encodeURI(key)
                                    $("#FTradeReceivablesUpdateSaleType_ShowSummary").loadUrl(url);
                                }
                                else {
                                    $("#FTradeReceivablesSaleTypeAdd_XiaoShouLeiXing").val("请选择");
                                    $("#FTradeReceivablesSaleTypeAdd_ShowXXLSPage").empty();
                                    alertMsg.warn('对不起,不能将[<%=obj.XiaoShouLeiXing %>]　变更成 [' + key + ']');
                                }
                            }
                            catch (e) {

                            }
                        }
                    });

                }

                changeXiaoShouLeiXingSaleTypeAdd("<%=obj.XiaoShouLeiXing %>");
            })
        </script>
        <div style="clear: both; margin-bottom: 5px;">
        </div>
    </div>
    <div class="formBar">
        <ul>
            <!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit">
                            下一步(收款)</button></div>
                </div>
            </li>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">
                            取消</button></div>
                </div>
            </li>
        </ul>
    </div>
    </form>
</div>
